package controller;
 
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import pojo.Author;
import pojo.Book;
import pojo.Topic;

import java.util.*;

import dao.AuthorDAO;
import dao.BookDAO;
import dao.TopicDAO;
 
@Controller
public class TrangchuController {
	
	List<Book> lBook;
    @RequestMapping("/trangchu")
    public ModelAndView helloWorld() {
 
        String message = "Hello World, Spring 3.0!";
        return new ModelAndView("TrangChu");
    }
    

    
    @RequestMapping(value={"/home","","Home","HOME"})
    public String hienTrangChu(HttpServletRequest request){
    	TopicDAO td=new TopicDAO();
    	BookDAO bd= new BookDAO();

    	List<Topic> lmenu = td.getMenuCap1();
    	List<Book> lb = bd.getNbookTopView(20);
    	List<Book> lb2= bd.getNewBook(20);

    	request.setAttribute("lBookTopView", lb);
    	request.setAttribute("lmenu",lmenu);
    	request.setAttribute("lBookNew", lb2);
    	return "page/FrontEnd/TrangChu";
    }
    
    @RequestMapping("/Huongdan.do")
    public String ShowHuongDan(HttpServletRequest request){
    	return "page/FrontEnd/HuongDan";
    }
    @RequestMapping(value="/Lienhe.do", method = RequestMethod.GET)
    public String ShowLienHe(HttpServletRequest request){
    	return "page/FrontEnd/LienHe";
    }
}